use std::{
    io::{Read, Write},
    net::TcpListener,
};

fn main() {
    // 创建服务端端口监听
    let listener = TcpListener::bind("127.0.0.1:3001").unwrap();
    println!("Runnning on port 3001..");
    // 监听信息
    for stream in listener.incoming() {
        // 创建一个buffer来接受信息
        let mut stream = stream.unwrap();
        let mut buffer = [0; 1024];
        stream.read(&mut buffer).unwrap();
        // 将接收到的信息原封不动的返回给客户端
        stream.write(&mut buffer).unwrap();
    }
}
